package com.play;

import com.play.domain.Status;
import com.play.domain.UpdateLogRequest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;

@RequestMapping("/log")
@Controller
public class LogController {

  @RequestMapping(method = RequestMethod.GET)
  public String getLogs(Map<String, Object> model) {

    List<Status> statusList = new ArrayList<>();

    for(int i=1; i< 4; i++){
      Status status = new Status();
      status.setId(i);
      status.setValue("status-" + i);
      statusList.add(status);
    }

    model.put("statusList", statusList);

    return "sendLog";
  }

  @ResponseBody
  @RequestMapping(value = "/save", method = RequestMethod.POST)
  public ResponseEntity save(HttpServletRequest request,
      @RequestBody List<UpdateLogRequest> updateLogRequests){

    System.out.println(updateLogRequests);
    return ResponseEntity.status(HttpStatus.OK).build();
  }


}